//
//  C205AccountViewController.m
//  云音乐
//
//  Created by lanou3g on 15/6/3.
//  Copyright (c) 2015年 C205. All rights reserved.
//
#define kMainScreenWidth [UIScreen mainScreen].bounds.size.width

#import "C205AccountViewController.h"
#import "C205PlayingMusicItemAnimate.h"
#import "C205LoginView.h"

@interface C205AccountViewController ()<UITableViewDelegate,UITableViewDataSource>
{
    UITableView * _table;
}
@end

@implementation C205AccountViewController
#pragma mark - 生命周期
#pragma mark -
- (void)loadView
{
    UITableView * tabelView = [[UITableView alloc]initWithFrame:[UIScreen mainScreen].bounds style:UITableViewStyleGrouped];
    _table = tabelView;
    self.view = tabelView;
}
- (void)viewDidLoad {
    [super viewDidLoad];
    _table.dataSource = self;
    _table.delegate = self;
}
- (void)viewDidAppear:(BOOL)animated
{
    [super viewDidAppear:YES];
    C205LoginView * view = [[C205LoginView alloc]initWithFrame:CGRectMake(0, 0, kMainScreenWidth, kMainScreenWidth/3.5) firstTitle:@"登陆网易云音乐" secondTitle:@"手机电脑多端同步，320k高品质无线下载" butTitle:@"立即登录"];
    _table.tableHeaderView = view;
    [self loadNavi];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
#pragma mark - 加载视图
#pragma mark -
- (void)loadNavi
{
    /**
     title
    */
    UILabel *label = [[UILabel alloc] initWithFrame:CGRectZero];
    label.backgroundColor = [UIColor clearColor];
    label.font = [UIFont boldSystemFontOfSize:18.0];
    label.textAlignment = NSTextAlignmentCenter;
    label.textColor = [UIColor whiteColor];
    self.navigationItem.titleView = label;
    label.text = @"账号";
    [label sizeToFit];
    
    /**
     *  右侧按钮
     */
    C205PlayingMusicItemAnimate * playingMusicItem = [[C205PlayingMusicItemAnimate alloc]init];
    self.navigationItem.rightBarButtonItem =  [[UIBarButtonItem alloc]initWithCustomView:playingMusicItem] ;
        
}

#pragma mark - UITableViewDataSource
#pragma mark -
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 3;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    if (section == 0) {
        return 1;
    }else if (section == 1){
        return 4;
    }else
    {
        return 2;
    }
        
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    NSArray * arrTitle = @[@"网易云音乐畅听流量包",@"换肤",@"定时关闭",@"设置"];
    NSArray * arrPic = @[@"cm2_set_icn_combo",@"cm2_set_icn_skin",@"cm2_set_icn_time",@"cm2_set_icn_set"];
    static NSString * str = @"Cell";
    UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:str];
    if (!cell) {
        cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:str];
    }
    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    if (indexPath.section == 0) {
        cell.textLabel.text = @"积分商城";
        cell.imageView.image = [UIImage imageNamed:@"cm2_set_icn_store"];
    }if (indexPath.section == 1) {
        cell.textLabel.text = arrTitle[indexPath.row];
        NSString * str = arrPic[indexPath.row];
        cell.imageView.image = [UIImage imageNamed:str];
        if (indexPath.row == 1) {
            cell.detailTextLabel.text = @"官方默认";
        }else if (indexPath.row == 2){
            cell.detailTextLabel.text = @"未开启";
        }
    }else{
        if (indexPath.row == 0) {
            cell.textLabel.text =@"分享网易云音乐";
            cell.imageView.image = [UIImage imageNamed:@"cm2_set_icn_share"];
        }else
        {
            cell.textLabel.text = @"关于";
            cell.imageView.image = [UIImage imageNamed:@"cm2_set_icn_about"];
        }
    }
    return cell;
}
#pragma mark - UITableViewDelegate
#pragma mark -
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    return 8;
}

- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
    return  0.1;
}
@end
